<template>
  <div>
    <h1>Grandson</h1>
    爷爷的钱包里有：{{ money }} 爷爷的车子是：{{ car.brand }} 价格是：{{
      car.price
    }}
    <button @click="useMoney">修改爷爷的钱包</button>
  </div>
</template>

<script setup lang="ts">
import { inject } from "vue";
let { money, useMoney } = inject("money", { money: 1000, useMoney: () => {} });
// 如果没有注入，则使用默认值
let car = inject("car", { brand: "宝马", price: 100000 });
</script>

<style scoped></style>
